/*
 * DirectedDiffusion.java
 *
 * @created Lundi 01/06/07
 *
 * @author bbrison
 */

package communication.thirdLayer;

import java.util.*;
import objects.*;

public class DirectedResults {
    
    private double _start;
    private double _over;

    private double _time;

    private HashMap<Sensor,Vector<MobileStation>> _primaryPath;

    public static final String ROUTING = "Routing";
    public static final String SUCCESS = "Success";
    public static final String FAILED = "Failed";
    private String _state;

    public DirectedResults() {
	_over = 0;
	_start = 0;
	_time = 0;
	_primaryPath = new HashMap<Sensor,Vector<MobileStation>>();
	_state = ROUTING;
	
    }
    
    public void setState(String s) {
	_state=s;
    }

    public void setStart(double x) {
	_start = x;
    }
    
    public void setOver(double x) {
	_over = x;
    }

      
    public void setTimeEllapsed() {
	_time = _over - _start;
    }

    public void addOnPrimary(Sensor sens, MobileStation s) {
	Vector<MobileStation> vect = _primaryPath.get(sens);
	if(vect != null) {
	    vect.add(s);
	} else{
	    Vector<MobileStation> v = new Vector<MobileStation>();
	    v.add(s);
	    _primaryPath.put(sens,v);
	}
	
    }

    public String getState() {
	return _state;
    }
    
    public double getTime() {
	return _time;
    }

    public double getTimeEllapsed() {
	return _time/1000;
    }
    
  
    public HashMap<Sensor,Vector<MobileStation>> getPrimaryPath() {
	return _primaryPath;
    }

    public String toString() {
	String res = "start: " + _start + "\n"+
	    "over: " + _over+ "\n" + 
	    "time ellapsed: " + _time + "\n" +
	    "primary path: " + _primaryPath +"\n";
	return res;	    
    }
    
}
